﻿using System;
using System.Net;
using SomeKit.Http;
using System.Collections.Generic;

#if WINDOWS_PHONE
using Microsoft.Phone.Reactive;
using System.Text;
#else
using System.Linq;
using System.Text;
#endif

namespace SomeKit.Rx.Http
{
    public static partial class HttpHelper
    {
        public static IObservable<string> Put(this Uri uri, string body, Action<HttpWebRequest> headerHandler = null)
        {
            var request = uri.GetRequest(SomeKit.Http.HttpHelper.Verbs.PUT, headerHandler);
            return PrepareBody(body, request);
        }

        public static IObservable<string> Put(this Uri uri, Action<HttpWebRequest> headerHandler = null)
        {
            return uri.Put(null, headerHandler);
        }

        public static IObservable<string> PutXml(this Uri uri, string body, Action<HttpWebRequest> headerHandler = null)
        {
            var request = uri.GetXmlRequest(SomeKit.Http.HttpHelper.Verbs.PUT, true, headerHandler);
            return PrepareBody(body, request);
        }

        public static IObservable<string> PutJson(this Uri uri, string body, Action<HttpWebRequest> headerHandler = null)
        {
            var request = uri.GetJsonRequest(SomeKit.Http.HttpHelper.Verbs.PUT, true, headerHandler);
            return PrepareBody(body, request);
        }
    }
}
